<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>

<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="list" checkbox="false" fitColumns="true"
  	 title="查阅预习资料" actionUrl="queryPreviewController.do?datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="文件类型"  field="fileType"  hidden="false" query="false"  queryMode="single"  width="120" formatterjs="function(v,rec){return v==0? '视频':'文档'}"></t:dgCol>
   <t:dgCol title="名称"  field="name"  hidden="false"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="是否必学"  field="isMustLearn"  hidden="false" query="false" queryMode="single"  width="120" formatterjs="function(v,rec){return v==1? '是':'否'}"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgFunOpt title="下载" funname="downloadFile(id)"/>
  </t:datagrid>
  </div>
 </div>
 <script>
 function downloadFile(id){
		$.ajax({
			url: 'cms-attach.do?hasFile',
			dataType: 'json',
			data: {'ownerId':id},
			success: function(data){
				if(data.success){
					window.location.href="cms-attach.do?download&ownerId="+id;
				}else{
					tip(data.msg);
					return;
				}
			}
		});
	}
 </script>